home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / uemacs-3.000 / uemacs-3 / uemacs-3.8 / estruct.h,v < prev    next >
Encoding:
Text File  |  1995-09-22  |  17.9 KB  |  514 lines

  1. head    1.1;
  2. access;
  3. symbols;
  4. locks
  5.     moss:1.1; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.1
  10. date    95.09.22.22.58.36;    author moss;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19. 1.1
  20. log
  21. @Initial revision
  22. @
  23. text
  24. @/*    ESTRUCT:    Structure and preprocesser defined for
  25.             MicroEMACS 3.8
  26.  
  27.             written by Dave G. Conroy
  28.             modified by Steve Wilhite, George Jones
  29.             greatly modified by Daniel Lawrence
  30. */
  31.  
  32. #ifdef    LATTICE
  33. #undef    LATTICE        /* don't use their definitions...use ours    */
  34. #endif
  35. #ifdef    MSDOS
  36. #undef    MSDOS
  37. #endif
  38. #ifdef    CPM
  39. #undef    CPM
  40. #endif
  41. #ifdef    AMIGA
  42. #undef    AMIGA
  43. #endif
  44.  
  45. /*    Version definition            */
  46.  
  47. #define    VERSION    "3.8b"
  48.  
  49. /*    Machine/OS definitions            */
  50.  
  51. #define AMIGA   0                       /* AmigaDOS            */
  52. #define ST520   0                       /* ST520, TOS                   */
  53. #define MSDOS   1                       /* MS-DOS                       */
  54. #define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
  55. #define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  56. #define    USG    0            /* UNIX system V        */
  57. #define VMS     0                       /* VAX/VMS                      */
  58. #define CPM     0                       /* CP/M-86                      */
  59. #define    FINDER    0            /* Macintosh OS            */
  60.  
  61. /*    Compiler definitions            */
  62. #define MWC86   0    /* marc williams compiler */
  63. #define    LATTICE    0    /* Lattice 2.14 thruough 3.0 compilers */
  64. #define    AZTEC    1    /* Aztec C 3.20e */
  65. #define    MSC    0    /* MicroSoft C compile version 3 */
  66. #define MEGAMAX 0    /* Megamax C compiler */
  67.  
  68. /*    Profiling options    */
  69. #define    APROF    0    /* turn Aztec C profiling on? */
  70. #define    NBUCK    100    /* number of buckets to profile */
  71. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  72. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  73.  
  74. /*   Special keyboard definitions            */
  75.  
  76. #define WANGPC    0        /* WangPC - mostly escape sequences     */
  77.  
  78. /*    Terminal Output definitions        */
  79.  
  80. #define ANSI    0            /* ansi escape sequences    */
  81. #define    HP150    0            /* HP150 screen driver        */
  82. #define    HP110    0            /* HP110 screen driver        */
  83. #define    VMSVT    0            /* various VMS terminal entries    */
  84. #define VT52    0                       /* VT52 terminal (Zenith).      */
  85. #define VT100   0                       /* Handle VT100 style keypad.   */
  86. #define LK201   0                       /* Handle LK201 style keypad.   */
  87. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  88. #define TERMCAP 0                       /* Use TERMCAP                  */
  89. #define    IBMPC    1            /* IBM-PC CGA/MONO driver    */
  90. #define    EGA    0            /* EGA IBM-PC specific driver    */
  91. #define    DG10    0            /* Data General system/10    */
  92. #define    TIPC    0            /* TI Profesional PC driver    */
  93. #define    MAC    0            /* Macintosh            */
  94. #define    ATARI    0            /* Atari 520/1040ST screen    */
  95.  
  96. /*    Configuration options    */
  97.  
  98. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  99. #define    NFWORD    1    /* forward word jumps to beginning of word    */
  100. #define    CLRMSG    0    /* space clears the message line with no insert    */
  101. #define    ACMODE    1    /* auto CMODE on .C and .H files        */
  102. #define    CFENCE    1    /* fench matching in CMODE            */
  103. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  104. #define DEBUGM    1    /* Global SPELL mode triggers macro debugging    */
  105. #define    VISMAC    0    /* update display during keyboard macros    */
  106. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  107.  
  108. #define    REVSTA    1    /* Status line appears in reverse video        */
  109. #define    COLOR    1    /* color commands and windows            */
  110.  
  111. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  112. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  113. #define    WORDPRO    1    /* Advanced word processing features        */
  114. #define    FLABEL    0    /* function key label code            */
  115. #define    APROP    1    /* Add code for Apropos command            */
  116. #define    CRYPT    1    /* file encryption enabled?            */
  117. #define MAGIC    1    /* include regular expression matching?        */
  118.  
  119. #define ASCII    1    /* always using ASCII char sequences for now    */
  120. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  121.  
  122. /*    System dependant library redefinitions, structures and includes    */
  123.  
  124. /*  Megamax C defines short to be 1 byte and int to be 2 bytes */
  125. #if    MEGAMAX & ST520
  126. #define SHORT int
  127. #else
  128. #define SHORT short
  129. #endif
  130.  
  131. #if    AZTEC
  132. #undef    fputc
  133. #undef    fgetc
  134. #define    fputc    aputc
  135. #define    fgetc    agetc
  136. #define    int86    sysint
  137. #define    intdos(a, b)    sysint(33, a, b)
  138. #define    inp    inportb
  139.  
  140. struct XREG {
  141.     int ax,bx,cx,dx,si,di;
  142. };
  143.  
  144. struct HREG {
  145.     char al,ah,bl,bh,cl,ch,dl,dh;
  146. };
  147.  
  148. union REGS {
  149.     struct XREG x;
  150.     struct HREG h;
  151. };
  152. #endif
  153.  
  154. #if    MSDOS & MWC86
  155. #include    <dos.h>
  156. #define    int86(a, b, c)    intcall(b, c, a)
  157. #define    inp    in
  158.  
  159. struct XREG {
  160.     int ax,bx,cx,dx,si,di,ds,es,flags;
  161. };
  162.  
  163. struct HREG {
  164.     char al,ah,bl,bh,cl,ch,dl,dh;
  165.     int ds,es,flags;
  166. };
  167.  
  168. union REGS {
  169.     struct XREG x;
  170.     struct HREG h;
  171. };
  172. #endif
  173.  
  174. #if    MSDOS & MSC
  175. #include    <dos.h>
  176. #define    movmem(a, b, c)        memcpy(b, a, c)
  177. #endif
  178.  
  179. #if    MSDOS & LATTICE
  180. #undef    CPM
  181. #undef    LATTICE
  182. #include    <dos.h>
  183. #undef    CPM
  184. #endif
  185.  
  186. #if    VMS
  187. #define    unlink(a)    delete(a)
  188. #endif
  189.  
  190. /*    define memory mapped flag    */
  191.  
  192. #define    MEMMAP    0
  193.  
  194. #if    IBMPC
  195. #undef    MEMMAP
  196. #define    MEMMAP    1
  197. #endif
  198.  
  199. #if    IBMMONO
  200. #undef    MEMMAP
  201. #define    MEMMAP    1
  202. #endif
  203.  
  204. #if    EGA
  205. #undef    MEMMAP
  206. #define    MEMMAP    1
  207. #endif
  208.  
  209. /*    internal constants    */
  210.  
  211. #define    NBINDS    256            /* max # of bound keys        */
  212. #define NFILEN  80                      /* # of bytes, file name        */
  213. #define NBUFN   16                      /* # of bytes, buffer name      */
  214. #define NLINE   256                     /* # of bytes, line             */
  215. #define    NSTRING    128            /* # of bytes, string buffers    */
  216. #define NKBDM   256                     /* # of strokes, keyboard macro */
  217. #define NPAT    128                     /* # of bytes, pattern          */
  218. #define HUGE    1000                    /* Huge number                  */
  219. #define    NLOCKS    100            /* max # of file locks active    */
  220. #define    NCOLORS    8            /* number of supported colors    */
  221. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  222. #define    NBLOCK    16            /* line block chunk size    */
  223. #define    NVSIZE    10            /* max #chars in a var name    */
  224.  
  225. #if    0
  226. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  227. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  228. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  229. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  230. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  231. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  232. #endif
  233.  
  234. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  235. #define META    0x0200                  /* Meta flag, or'ed in          */
  236. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  237. #define    SPEC    0x0800            /* special key (function keys)    */
  238.  
  239. #define FALSE   0                       /* False, no, bad, etc.         */
  240. #define TRUE    1                       /* True, yes, good, etc.        */
  241. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  242. #define    FAILED    3            /* not-quite fatal false return    */
  243. #define    RET    4            /* a return from buffer        */
  244. #define    GOLINE    5            /* exit flagging a GOTO        */
  245.  
  246. #define    STOP    0            /* keyboard macro not in use    */
  247. #define    PLAY    1            /*          playing    */
  248. #define    RECORD    2            /*          recording    */
  249.  
  250. #define    FORWARD    0            /* forward direction        */
  251. #define REVERSE    1            /* backwards direction        */
  252.  
  253. #define FIOSUC  0                       /* File I/O, success.           */
  254. #define FIOFNF  1                       /* File I/O, file not found.    */
  255. #define FIOEOF  2                       /* File I/O, end of file.       */
  256. #define FIOERR  3                       /* File I/O, error.             */
  257. #define    FIOLNG    4            /* line longer than allowed len    */
  258. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  259.  
  260. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  261. #define CFKILL  0x0002                  /* Last command was a kill      */
  262.  
  263. #define    BELL    0x07            /* a bell character        */
  264. #define    TAB    0x09            /* a tab character        */
  265.  
  266. #if    V7 | USG | BSD
  267. #define    PATHCHR    ':'
  268. #else
  269. #define    PATHCHR    ';'
  270. #endif
  271.  
  272. #define    INTWIDTH    sizeof(int)/3 + 2
  273.  
  274. /*    Macro argument token types                    */
  275.  
  276. #define    TKNUL    0            /* end-of-string        */
  277. #define    TKARG    1            /* interactive argument        */
  278. #define    TKBUF    2            /* buffer argument        */
  279. #define    TKVAR    3            /* user variables        */
  280. #define    TKENV    4            /* environment variables    */
  281. #define    TKFUN    5            /* function....            */
  282. #define    TKDIR    6            /* directive            */
  283. #define    TKLBL    7            /* line label            */
  284. #define    TKLIT    8            /* numeric literal        */
  285. #define    TKSTR    9            /* quoted string literal    */
  286. #define    TKCMD    10            /* command name            */
  287.  
  288. /*    Internal defined functions                    */
  289.  
  290. /* DIFCASE represents the integer difference between upper
  291.    and lower case letters.  It is an xor-able value, which is
  292.    fortunate, since the relative positions of upper to lower
  293.    case letters is the opposite of ascii in ebcdic.
  294. */
  295.  
  296. #ifdef    islower
  297. #undef    islower
  298. #endif
  299.  
  300. #if    ASCII
  301.  
  302. #define    DIFCASE        0x20
  303. #define isletter(c)    (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
  304. #define islower(c)    (('a' <= c && 'z' >= c))
  305. #endif
  306.  
  307. #if    EBCDIC
  308.  
  309. #define    DIFCASE        0x40
  310. #define isletter(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
  311. #define islower(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
  312. #endif
  313.  
  314. /*    Dynamic RAM tracking and reporting redefinitions    */
  315.  
  316. #if    RAMSIZE
  317. #define    malloc    allocate
  318. #define    free    release
  319. #endif
  320.  
  321. /*
  322.  * There is a window structure allocated for every active display window. The
  323.  * windows are kept in a big list, in top to bottom screen order, with the
  324.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  325.  * The flag field contains some bits that are set by commands to guide
  326.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  327.  * the full blown redisplay is just too expensive to run for every input
  328.  * character.
  329.  */
  330. typedef struct  WINDOW {
  331.         struct  WINDOW *w_wndp;         /* Next window                  */
  332.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  333.         struct  LINE *w_linep;          /* Top line in the window       */
  334.         struct  LINE *w_dotp;           /* Line containing "."          */
  335.         short   w_doto;                 /* Byte offset for "."          */
  336.         struct  LINE *w_markp;          /* Line containing "mark"       */
  337.         short   w_marko;                /* Byte offset for "mark"       */
  338.         char    w_toprow;               /* Origin 0 top row of window   */
  339.         char    w_ntrows;               /* # of rows of text in window  */
  340.         char    w_force;                /* If NZ, forcing row.          */
  341.         char    w_flag;                 /* Flags.                       */
  342. #if    COLOR
  343.     char    w_fcolor;        /* current forground color    */
  344.     char    w_bcolor;        /* current background color    */
  345. #endif
  346. }       WINDOW;
  347.  
  348. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  349. #define WFMOVE  0x02                    /* Movement from line to line   */
  350. #define WFEDIT  0x04                    /* Editing within a line        */
  351. #define WFHARD  0x08                    /* Better to a full display     */
  352. #define WFMODE  0x10                    /* Update mode line.            */
  353. #define    WFCOLR    0x20            /* Needs a color change        */
  354.  
  355. /*
  356.  * Text is kept in buffers. A buffer header, described below, exists for every
  357.  * buffer in the system. The buffers are kept in a big list, so that commands
  358.  * that search for a buffer by name can find the buffer header. There is a
  359.  * safe store for the dot and mark in the header, but this is only valid if
  360.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  361.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  362.  * the header line in "b_linep".
  363.  *     Buffers may be "Inactive" which means the files accosiated with them
  364.  * have not been read in yet. These get read in at "use buffer" time.
  365.  */
  366. typedef struct  BUFFER {
  367.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  368.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  369.         short   b_doto;                 /* Offset of "." in above LINE  */
  370.         struct  LINE *b_markp;          /* The same as the above two,   */
  371.         short   b_marko;                /* but for the "mark"           */
  372.         struct  LINE *b_linep;          /* Link to the header LINE      */
  373.     char    b_active;        /* window activated flag    */
  374.         char    b_nwnd;                 /* Count of windows on buffer   */
  375.         char    b_flag;                 /* Flags                        */
  376.     char    b_mode;            /* editor mode of this buffer    */
  377.         char    b_fname[NFILEN];        /* File name                    */
  378.         char    b_bname[NBUFN];         /* Buffer name                  */
  379. #if    CRYPT
  380.     char    b_key[NPAT];        /* current encrypted key    */
  381. #endif
  382. }       BUFFER;
  383.  
  384. #define BFINVS  0x01                    /* Internal invisable buffer    */
  385. #define BFCHG   0x02                    /* Changed since last write     */
  386.  
  387. /*    mode flags    */
  388. #define    NUMMODES    8        /* # of defined modes        */
  389.  
  390. #define    MDWRAP    0x0001            /* word wrap            */
  391. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  392. #define    MDSPELL    0x0004            /* spell error parcing        */
  393. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  394. #define    MDVIEW    0x0010            /* read-only buffer        */
  395. #define MDOVER    0x0020            /* overwrite mode        */
  396. #define MDMAGIC    0x0040            /* regular expresions in search */
  397. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  398.  
  399. /*
  400.  * The starting position of a region, and the size of the region in
  401.  * characters, is kept in a region structure.  Used by the region commands.
  402.  */
  403. typedef struct  {
  404.         struct  LINE *r_linep;          /* Origin LINE address.         */
  405.         short   r_offset;               /* Origin LINE offset.          */
  406.         long    r_size;                 /* Length in characters.        */
  407. }       REGION;
  408.  
  409. /*
  410.  * All text is kept in circularly linked lists of "LINE" structures. These
  411.  * begin at the header line (which is the blank line beyond the end of the
  412.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  413.  * number of bytes in the line (the "used" size), the size of the text array,
  414.  * and the text. The end of line is not stored as a byte; it's implied. Future
  415.  * additions will include update hints, and a list of marks into the line.
  416.  */
  417. typedef struct  LINE {
  418.         struct  LINE *l_fp;             /* Link to the next line        */
  419.         struct  LINE *l_bp;             /* Link to the previous line    */
  420.         short   l_size;                 /* Allocated size               */
  421.         short   l_used;                 /* Used size                    */
  422.         char    l_text[1];              /* A bunch of characters.       */
  423. }       LINE;
  424.  
  425. #define lforw(lp)       ((lp)->l_fp)
  426. #define lback(lp)       ((lp)->l_bp)
  427. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  428. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  429. #define llength(lp)     ((lp)->l_used)
  430.  
  431. /*
  432.  * The editor communicates with the display using a high level interface. A
  433.  * "TERM" structure holds useful variables, and indirect pointers to routines
  434.  * that do useful operations. The low level get and put routines are here too.
  435.  * This lets a terminal, in addition to having non standard commands, have
  436.  * funny get and put character code too. The calls might get changed to
  437.  * "termp->t_field" style in the future, to make it possible to run more than
  438.  * one terminal type.
  439.  */
  440. typedef struct  {
  441.     short    t_mrow;            /* max number of rows allowable */
  442.         short   t_nrow;                 /* current number of rows used  */
  443.         short   t_mcol;                 /* max Number of columns.       */
  444.         short   t_ncol;                 /* current Number of columns.   */
  445.     short    t_margin;        /* min margin for extended lines*/
  446.     short    t_scrsiz;        /* size of scroll region "    */
  447.     int    t_pause;        /* # times thru update to pause */
  448.         int     (*t_open)();            /* Open terminal at the start.  */
  449.         int     (*t_close)();           /* Close terminal at end.       */
  450.     int    (*t_kopen)();        /* Open keyboard        */
  451.     int    (*t_kclose)();        /* close keyboard        */
  452.         int     (*t_getchar)();         /* Get character from keyboard. */
  453.         int     (*t_putchar)();         /* Put character to display.    */
  454.         int     (*t_flush)();           /* Flush output buffers.        */
  455.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  456.         int     (*t_eeol)();            /* Erase to end of line.        */
  457.         int     (*t_eeop)();            /* Erase to end of page.        */
  458.         int     (*t_beep)();            /* Beep.                        */
  459.     int    (*t_rev)();        /* set reverse video state    */
  460.     int    (*t_rez)();        /* change screen resolution    */
  461. #if    COLOR
  462.     int    (*t_setfor)();        /* set forground color        */
  463.     int    (*t_setback)();        /* set background color        */
  464. #endif
  465. }       TERM;
  466.  
  467. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  468.                         dependant place later)    */
  469.  
  470. #define    TTopen        (*term.t_open)
  471. #define    TTclose        (*term.t_close)
  472. #define    TTkopen        (*term.t_kopen)
  473. #define    TTkclose    (*term.t_kclose)
  474. #define    TTgetc        (*term.t_getchar)
  475. #define    TTputc        (*term.t_putchar)
  476. #define    TTflush        (*term.t_flush)
  477. #define    TTmove        (*term.t_move)
  478. #define    TTeeol        (*term.t_eeol)
  479. #define    TTeeop        (*term.t_eeop)
  480. #define    TTbeep        (*term.t_beep)
  481. #define    TTrev        (*term.t_rev)
  482. #define    TTrez        (*term.t_rez)
  483. #if    COLOR
  484. #define    TTforg        (*term.t_setfor)
  485. #define    TTbacg        (*term.t_setback)
  486. #endif
  487.  
  488. /*    structure for the table of initial key bindings        */
  489.  
  490. typedef struct  {
  491.         short   k_code;                 /* Key code                     */
  492.         int     (*k_fp)();              /* Routine to handle it         */
  493. }       KEYTAB;
  494.  
  495. /*    structure for the name binding table        */
  496.  
  497. typedef struct {
  498.     char *n_name;        /* name of function key */
  499.     int (*n_func)();    /* function name is bound to */
  500. }    NBIND;
  501.  
  502. /*    The editor holds deleted text chunks in the KILL buffer. The
  503.     kill buffer is logically a stream of ascii characters, however
  504.     due to its unpredicatable size, it gets implemented as a linked
  505.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  506.     was taken up by the keycode structure)            */
  507.  
  508. typedef    struct KILL {
  509.     struct KILL *d_next;    /* link to next chunk, NULL if last */
  510.     char d_chunk[KBLOCK];    /* deleted text */
  511. } KILL;
  512.  
  513. @
  514.